#include <bits/stdc++.h>

using namespace std;

#define in read()

const int MAXN = 10010;
const int MAXE = 5e6+10;

typedef struct{int v,nxt;}edge;
int dfn[MAXN],low[MAXN],tot,stk[MAXN],top,h[MAXN],cnt,to[MAXN],nodenum,blo[MAXN],fro[MAXN],n;
bool vis[MAXN];
edge e[MAXE];

void link(int x,int y){e[++cnt] = (edge){y,h[x]};h[x] = cnt;}

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1) + (x<<3) + (ch^48);
	return x * sgn;
}

void dfs(int x){
	low[x] = dfn[x] = ++tot; vis[x] = 1;stk[++top] = x;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v;
		if(!dfn[y]) dfs(y),low[x] = min(low[x],low[y]);
		else if(vis[y]) low[x] = min(low[x],dfn[y]);
	}
	if(low[x] == dfn[x]){
		int y;++nodenum;
		do{
			y = stk[top--];
			vis[y] = 0;
			blo[y] = nodenum;
		}while(y != x);
	}
}

int main (){
	n = in;
	for(int i = 1;i <= n;i++){
		int x = in;
		while(x){link(i,x);x=in;}
	}
	for(int i = 1;i <= n;i++) if(!dfn[i]) dfs(i);
	for(int i = 1;i <= n;i++)
		for(int j = h[i];j;j = e[j].nxt){
			int y = e[j].v;
			if(blo[i] != blo[y]){
				to[blo[y]]++;fro[blo[i]]++;
			}
		}
	int ans1 = 0 , ans2 = 0;
	for(int i = 1;i <= nodenum;i++){
		if(!to[i]) ans1++;
		if(!fro[i]) ans2++;
	}
	if(nodenum == 1) printf("1\n0\n");
	else printf("%d\n%d\n",ans1,max(ans1,ans2));
	return 0;
}
